package bean;

/**
 *
 * @author enemY
 */
public class RawMessage {
    private int messageId;
    private MessageType messageType;
    private String recipientMSISDN;
    private String rawMessage;
    private MessageStatus status;
    private MessageSource source;

    public static enum MessageType {
        BINARY(20), PLAIN(21);
        private final int type;

        MessageType(int type) {
            this.type = type;
        }

        public int intValue() {
            return type;
        }

        public static MessageType getMessageType(int type) {
            for (MessageType knownType : values()) {
                if (knownType.intValue() == type) {
                    return knownType;
                }
            }
            return null;
        }
    }

    public static enum MessageSource {
        MESSAGEOUTBOX, PROGRAM_UPDATE_NUMBERS;
    }

    public static enum MessageStatus {
        DONT_TOUCH(0), TAKE(1), TAKEN(2), SUBMITTED(3), DELIVERED(4), FAILED(5);
        private final int status;

        MessageStatus(int status) {
            this.status = status;
        }

        public int intValue() {
            return status;
        }

        public static MessageStatus getMessageStatus(int status) {
            for (MessageStatus knownStatus : values()) {
                if (knownStatus.intValue() == status) {
                    return knownStatus;
                }
            }
            return null;
        }
    }

    public int getMessageId() {
        return messageId;
    }

    public void setMessageId(int messageId) {
        this.messageId = messageId;
    }

    public MessageType getMessageType() {
        return messageType;
    }

    public void setMessageType(MessageType messageType) {
        this.messageType = messageType;
    }

    public void setMessageType(int messageType) {
        this.messageType = MessageType.getMessageType(messageType);
    }

    public String getRecipientMSISDN() {
        return recipientMSISDN;
    }

    public void setRecipientMSISDN(String recipientMSISDN) {
        this.recipientMSISDN = recipientMSISDN;
    }

    public String getRawMessage() {
        return rawMessage;
    }

    public void setRawMessage(String rawMessage) {
        this.rawMessage = rawMessage;
    }

    public MessageStatus getMessageStatus() {
        return status;
    }

    public void setMessageStatus(MessageStatus status) {
        this.status = status;
    }

    public void setMessageStatus(int status) {
        this.status = MessageStatus.getMessageStatus(status);
    }
}

